local M = {}

local propUI = require("prop.propUI")

function M.createPosition(obj)
	local gPos = display.newGroup()


	local title = propUI.createText("Position")
	gPos:insert(title)

	local function onSubmit(event)
		obj.x = tonumber(event.target.text)
		eventDispatcher:dispatchEvent("chooseObj", {target = obj})
	end
	local gX = propUI.createTextWithInput("X", obj.x, "number", onSubmit)
	gPos:insert(gX)
	gX.x, gX.y = title.x + title.width + 30, title.y


	local function onSubmit1(event)
		obj.y = tonumber(event.target.text)
		eventDispatcher:dispatchEvent("chooseObj", {target = obj})
	end
	local gY = propUI.createTextWithInput("Y", obj.y, "number", onSubmit1)
	gPos:insert(gY)
	gY.x, gY.y = gX.x + gX.width + 15, gX.y


	local function onMove(event)
		gX:setText(event.target.x)
		gY:setText(event.target.y)
	end
	eventDispatcher:addEventListener(
			"chooseObjMove",
			onMove,
			function()
				return not coreDisplay.isDisplayObj(gPos)
			end
	)
	return gPos
end

return M